public class Demo_903 {
    public static void main(String[] args) {
       Student s1 = Student.createStudentByAgeAndName(18,"张三");
       Student s2 = Student.createStudentByClassIdAndName(1,"李四");
    }
}


//定义一个Student类
class Student{
    private int id;
    private int age;
    private int classId;
    private String name;
    private String sno;

    public Student(){

    }

    //通过age和name初始化一个对象
    public static Student createStudentByAgeAndName(int age,String name){
        Student student = new Student();
        student.setAge(age);
        student.setName(name);
        return student;
    }

    //通过class和name初始化一个对象
    public static Student createStudentByClassIdAndName(int classId,String name){
        Student student = new Student();
        student.setClassId(classId);
        student.setName(name);
        return student;
    }


    public int getId(){
        return id;
    }

    public void setId(int id){
        this.id = id;
    }

    public int getAge(){
        return age;
    }

    public void setAge(int age){
        this.age = age;
    }

    public int getClassId(){
        return classId;
    }

    public void setClassId(int ClassId){
        this.classId = classId;
    }

    public String getName(){
        return name;
    }

    public void setName(String name){
        this.name = name;
    }
}

